package dddcore

import "context"

type BusChan struct {
	RespMsg string
	ErrMsg  error
}

type CommandHandler func(ctx context.Context, payload []byte, out chan<- BusChan)
type CommandHandlerMap func(ctx context.Context, payload map[string]string, out chan<- BusChan)

type CommandBus interface {
	Publish(ctx context.Context, command string, payload interface{}, out chan<- BusChan)
	Subscribe(command string, fn CommandHandler) error
	SubscribeMap(command string, fn CommandHandlerMap) error
	Unsubscribe(command string, fn CommandHandler) error
	UnsubscribeMap(command string, fn CommandHandlerMap) error
}
